home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_02_11
/
2n11075a
< prev
next >
Wrap
Text File
|
1991-09-29
|
24KB
|
705 lines
// VCR.CPP - VCR device driver class.
// VCR::VCR - Constructor for VCR
// VCR::~VCR - Destructor for VCR
// VCR::SendCommand - Send command string to VCR
// VCR::Stop - Puts the VCR into Stop mode.
// VCR::Eject - Causes the tape to be ejected from the VCR.
// VCR::Rewind - Places the VCR into full speed rewind.
// VCR::FastForward - Places the VCR into full speed fast forward.
// VCR::PlayFastReverse - Places the VCR into fast reverse play.
// VCR::PlayFastForward - Places the VCR into fast forward play.
// VCR::Still - Causes the VCR to Still on the current frame.
// VCR::Record - Begin recording mode.
// VCR::Play - Begins normal play mode.
// VCR::ReversePlay - Begins normal reverse play mode;
// VCR::StepForward - From a still frame, advance to next field.
// VCR::StepReverse - From a still frame, step to previous field.
// VCR::PowerToggle - Toggle VCR power.
// VCR::ValidateFrame - Adjust frame format to ensure validity
// VCR::ReceiveResponse - Receive VCR response to request
// VCR::ShuttleOn - Enables jog/shuttle mode
// VCR::ShuttleUp - Increase shuttle speed
// VCR::ShuttleDown - Decrease shuttle speed
// VCR::ForwardShuttle - Forward shuttle
// VCR::ReverseShuttle - Reverse Shuttle
// VCR::CueToFrame - Cue to frame
// VCR::SetCueType - Set cue type
// VCR::PlayToFrame - Play to frame
// VCR::PlaySegment - Play segment
// VCR:AudioInsertToFrame - Audio insert to frame
// VCR::AudioVideoInsertToFrame - Audio/Video insert to frame
// VCR::Preplay - Preroll play
// VCR::Calibrate - Calibrate
// VCR::ClearCounter - Clear frame count
// VCR::AudioSelect - Audio select
// VCR::ResetVCR - Perform VCR reset
// VCR::RequestFrame - Request current frame count
// VCR::RequestMode - Request current VCR mode
#include <stdio.h>
#include "VCR.h"
/******************************************************************
* VCR::ReceiveResponse - Receive VCR response to command
*
*
* Class Variables Used:
* Port *SerialPort
*
* Returns:
* Str sResponse
*
* Copyright:
* Original code by William H. Roetzheim (619) 669-6970
* Copyright (c) 1991 by William H. Roetzheim
* All rights reserved.
**********************************************************************/
Str VCR::ReceiveResponse (void)
{
int i = 0;
char szBuffer [21];
// wait for start of command string
while (i != 0x02) i = spSerialPort->InChar();
// Receive actual response
int nBufferIndex = 0;
i = spSerialPort->InChar ();
while (i != 0x03)
{
szBuffer [nBufferIndex++] = i;
i = spSerialPort->InChar ();
}
szBuffer [nBufferIndex] = 0;
return (Str) szBuffer;
}
/******************************************************************
* VCR::ValidateFrame - Adjust frame fields to ensure validity
*
* Parameters:
* struct Frame& sfFrame (in/out) - frame to be adjusted.
*
**********************************************************************/
void VCR::ValidateFrame (struct Frame& sfFrame)
{
// If out of range, attempt to bring into range
if (sfFrame.nFrame < 0) sfFrame.nFrame = 0;
sfFrame.nSecond += (sfFrame.nFrame / 30);
sfFrame.nFrame %= 30;
if (sfFrame.nSecond < 0) sfFrame.nSecond = 0;
sfFrame.nMinute += (sfFrame.nSecond / 60);
sfFrame.nSecond %= 60;
if (sfFrame.nMinute < 0) sfFrame.nMinute = 0;
sfFrame.nHour += (sfFrame.nMinute / 60);
sfFrame.nMinute %= 60;
if (sfFrame.nHour < 0) sfFrame.nHour = 0;
if (sfFrame.nHour > 9) sfFrame.nHour = 9;
}
/******************************************************************
* VCR::ShuttleOn - Enables jog/shuttle mode
*
* Notes:
* 1. When received, the VCR enters the shuttle mode. This
* enables the shuttle up/down commands and the field
* step commands.
*
* 2. The VCR responds to this command by Still framing at
* the current tape position.
*
* 3. Executing Still or Stop commands will terminate this
* mode.
*
* 4. Command duration is 300 mSec. Up to 1 seconds may be
* required for the VCR to obtain a clean still frame.
*
* 5. Audio is muted, video playback is output.
*
**********************************************************************/
void VCR::ShuttleOn (void)
{
SendCommand ("A@S");
}
/******************************************************************
* VCR::ShuttleUp - Increase shuttle speed
*
* Notes:
* 1. Each time this command is received, the VCR increases
* the speed of the shuttle mode playback. This is
* equivalent to turning the shuttle ring on the VCR
* clockwise.
*
* 2. From a still frame, each command steps through 9
* speeds, varying from slow field advance to fast
* forward playback.
*
* 3. Once maximum speed is attained, additional commands have
* no effect.
*
* 4. Maximum command duration is 300 mSec.
*
* 5. Audio is muted in all but normal playback speed, video
* is output at all speeds.
*
**********************************************************************/
void VCR::ShuttleUp (void)
{
SendCommand ("A@O");
}
/******************************************************************
* VCR::ShuttleDown - Decrease shuttle speed
*
* Notes:
* 1. Each time this command is received, the VCR decreases
* the speed of the shuttle mode playback. This is
* equivalent to turning the shuttle ring on the VCR
* counterclockwise.
*
* 2. From a still frame, each command steps through 9
* speeds, varying from slow field advance to fast
* reverse playback.
*
* 3. Once maximum speed is attained, additional commands have
* no effect.
*
* 4. Maximum command duration is 300 mSec.
*
* 5. Audio is muted in all but normal playback speed, video
* is output at all speeds.
*
**********************************************************************/
void VCR::ShuttleDown (void)
{
SendCommand ("A@P");
}
/******************************************************************
* VCR::ForwardShuttle - Forward shuttle
*
* Parameters:
* int nSpeed - Speed in range of 0 to 8
*
* Notes:
* 1. This command places the VCR into the forward shuttle
* mode at the specified speed. When changing shuttle
* speeds, the VCR will gradually change from the
* current speed to the new speed.
*
* 2. A speed of 0 will select still frame. To freeze the
* picture faster, use ShuttleOn() instead.
*
* 3. The speed argument consists of a number from 0 to 8,
* where 8 is the maximum forward play speed. Numbers
* outside of this range are brought into range.
*
* 4. It may take several seconds to change from the current
* speed to the specified speed.
*
* 5. Video is output in all modes, audio is output at normal
* play speed.
*
**********************************************************************/
void VCR::ForwardShuttle (int nSpeed)
{
char szBuffer [6];
if (nSpeed < 0) nSpeed = 0;
if (nSpeed > 8) nSpeed = 8;
sprintf (szBuffer, "AAF%d", nSpeed);
SendCommand (szBuffer);
}
/******************************************************************
* VCR::ReverseShuttle - Reverse shuttle
*
* Parameters:
* int nSpeed - Speed in range of 0 to 8
*
* Notes:
* 1. This command places the VCR into the reverse shuttle
* mode at the specified speed. When changing shuttle
* speeds, the VCR will gradually change from the
* current speed to the new speed.
*
* 2. A speed of 0 will select still fr